<?php

namespace App\Http\Controllers\Admin;

use App\Repositories\System\FileRepository;
use App\Utils\Output;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;

/**
 * 文件
 * Class FileController
 * @package App\Http\Controllers\Admin
 */
class FileController extends Controller
{
    function uploadImage(Request $request, FileRepository $repository)
    {
        return $repository->image($request->allFiles(), $request->get('module', 'default'));
    }

    function uploadFile(Request $request, FileRepository $repository)
    {
        return $repository->file($request->allFiles(), $request->get('module', 'default'));
    }

    function editerImage(Request $request, FileRepository $repository)
    {
        $result = $repository->image($request->allFiles(), $request->get('module', 'default'));
        if($result->isSuccess()){
            return Output::data(['src'=>$result->data[0]['url']]);
        }
    }
}
